<?php

set_time_limit(0);
require_once 'db/Db.class.php';
require_once 'functions.php';
$db = new Db();
$sql = "SELECT * FROM records WHERE CrtDt <= :date";
$records = $db->query($sql,array('date' => date('Y-m-d H:i:s',strtotime('-48 hour'))));
foreach($records as $item){
    $file = PATH_ROOT.'video/'.$item['RecPath'];
    if(file_exists($file)){
        unlink($file);
    }
    $sql = "DELETE FROM `records` WHERE Id = :Id ";
    $dataUpdate['Id'] = $item['Id'];
    $db->query($sql,$dataUpdate);
    
}


